$(document).ready(function() {
    $("#qecode").on('click', function (e) {
        console.log("二维码！")
        e.preventDefault();
        $.ajax({
            type: 'post',
            url: '/user/qecode',
            dataType: "json",
            success: function (data) {
                console.log(data)
                console.log(data.bid)
                    $('body').html('')
                    var li = ''

                    li+='<form method="post">'
                    li+='<table>'
                    li+='<tr>'
                    li+='<td class="td_left"><label>编号</label></td>'
                    li+='<td class="td_right"><input type="text" name="bid" id="bid" placeholder="请输入编号"></td>'
                    li+='<td class="td_left"><label>书名</label></td>'
                    li+='<td class="td_right"><input type="text" name="bname" id="bname"  placeholder="请输入书名"></td>'
                    li+='</tr>'
                    li+='<tr>'
                    li+='<td class="td_left"><label>种类一</label></td>'
                    li+='<td class="td_right"><input type="text" name="category1" id="category1" placeholder="请输入种类一"></td>'
                    li+='<td class="td_left"><label>种类二</label></td>'
                    li+='<td class="td_right"><input type="text" name="category2" id="category2" placeholder="请输入种类二"></td>'
                    li+='</tr>'
                    li+='<tr>'
                    li+='<td class="td_left"><label>描述</label></td>'
                    li+='<td class="td_right"><input type="text" name="description" id="description" placeholder="请输入描述"></td>'
                    li+='<td class="td_left"><label>内容</label></td>'
                    li+='<td class="td_right"><input type="text" name="content" id="content"  placeholder="请输入内容">'
                    li+='</td>'
                    li+='</tr>'
                    li+='<tr>'
                    li+='<td class="td_left"><label>封面</label></td>'
                    li+='<td colspan="2" align="center">'
                    li+='<img width="200" height="200" id="uploadedImage" name="cover">'
                    li+='</td>'
                    li+='<td align="center">'
                    li+='<label for="imageUpload"  style="border-radius: 3px;border: 1px;color: white;background-color: cornflowerblue">'
                    li+='上传图片</label>'
                    li+='<input type="file" id="imageUpload" onchange="uploadImage()" name="cover"  style="display: none"></td>'
                    li+='</tr>'
                    li+='<tr>'
                    li+='<td class="td_left"><label>价格</label></td>'
                    li+='<td class="td_right"><input type="number" name="price" id="price" placeholder="请输入价格"></td>'
                    li+='<td class="td_left"><label>分数</label></td>'
                    li+='<td class="td_right"><input type="text" name="score" id="score"  placeholder="请输入分数"></td>'
                    li+='</tr>'
                    li+='<tr>'
                    li+='<td class="td_left"><label>作者</label></td>'
                    li+='<td class="td_right"><input type="text" name="author" id="author" placeholder="请输入作者"></td>'
                    li+='<td class="td_left"><label>出版社</label></td>'
                    li+='<td class="td_right"><input type="text" name="pubUnit" id="pubUnit"   placeholder="请输入出版社">'
                    li+='</td>'
                    li+='</tr>'
                    li+='<tr>'
                    li+='<td colspan="2" align="center">'
                    li+='<input type="submit" id="btn_sub" value="新增">'
                    li+='</td>'
                    li+='</tr>'
                    li+='</table>'
                    li+='</form>'
                    $('body').html(li)

                    const bid = document.getElementById("bid");
                    bid.value = data.bid;
                    const bname = document.getElementById("bname");
                    bname.value = data.bname;
                    const category1 = document.getElementById("category1");
                    category1.value = data.category1;
                    const category2 = document.getElementById("category2");
                    category2.value = data.category2;
                    const description = document.getElementById("description");
                    description.value = data.description;
                    const content = document.getElementById("content");
                    content.value = data.content;
                    const price = document.getElementById("price");
                    price.value = data.price;
                    const score = document.getElementById("score");
                    score.value = data.score;
                    const author = document.getElementById("author");
                    author.value = data.author;
                    const pubUnit = document.getElementById("pubUnit");
                    pubUnit.value = data.pubUnit;

                }})
            })
        });


